package cuiyt.juc.stream;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;

/**
 * @author cyt
 * @create 2020-05-02 8:38
 */
public class TestForkJoin {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        // 创建任务
        ForkJoinTask<Integer> forkjoin = new forkjoin(3);
        // 创建执行任务的 ForkJoinPool
        ForkJoinPool pool = new ForkJoinPool();
        // 提交任务
        ForkJoinTask<Integer> submit = pool.submit(forkjoin);
        // 得到结果
        Integer integer = submit.get();
        System.out.println(integer);
    }
}
